package com.lyshop.guiyingshanding.utils;

import com.lyshop.guiyingshanding.view.MoneyTextView;
import com.zc.mychart.model.GoodsItemBean;
import com.zc.mychart.utils.ArithUtil;
import com.zc.mychart.utils.FormatUtil;

public class GoodsUtils {

    public static double setGoodsMoneyCalculate(double last_price, int amount, GoodsItemBean bean, MoneyTextView mtv_material
            , MoneyTextView mtv_material_support, MoneyTextView mtv_premium, MoneyTextView mtv_loss, MoneyTextView mtv_technology, MoneyTextView mtv_taxes) {
        //原材料价格
        double material = ArithUtil.mul(ArithUtil.mul(last_price,bean.weight),amount);
        //辅料价格
        double material_support =  ArithUtil.mul(ArithUtil.mul(Double.parseDouble(bean.product_price),bean.material_ratio),amount);
        //原材料溢价费用
        double premium =  ArithUtil.mul(ArithUtil.mul(material,bean.premium_ratio),amount);
        //损耗费用
        double loss = ArithUtil.mul(ArithUtil.mul(Double.parseDouble(bean.product_price),bean.loss_ratio),amount);
        //工艺
        double technology =  ArithUtil.mul(ArithUtil.mul(Double.parseDouble(bean.product_price),bean.technology_ratio),amount);
        //税费
        double total = ArithUtil.add(ArithUtil.add(ArithUtil.add(ArithUtil.add(material, material_support), premium), loss), technology);
        double taxes = ArithUtil.mul(total,bean.taxes_ratio);
        total = ArithUtil.add(total,taxes);
        if(null != mtv_material){
            mtv_material.setText(FormatUtil.formatDouble2(material));
        }
        mtv_material_support.setText(FormatUtil.formatDouble2(material_support));
        mtv_premium.setText(FormatUtil.formatDouble2(premium));
        mtv_loss.setText(FormatUtil.formatDouble2(loss));
        mtv_technology.setText(FormatUtil.formatDouble2(technology));
        mtv_taxes.setText(FormatUtil.formatDouble2(taxes));
        return total;
    }
}
